﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Leikjavefurinn.Repo
{
	public class ApplesRepo
	{
		public GameDBDataContext _db = new GameDBDataContext();
		//User[] PlayerArr;
		//List<User> PlayerfArr = new List<User>();
		//String[] PlayerArr = new String[] { "PlayerOne", "PlayerTwo" };
		//User[] PlayerAffdrr = new User[] { };
		


		public IEnumerable<Game> AllGames()
		{
			return (from g in _db.Games select g).ToList();
		}

		public IEnumerable<ApplesToApple> AllApples()
		{
			return (from a in _db.ApplesToApples select a).ToList();
		}

		public ApplesToApple GetGameByID(Guid id)
		{
			return (from game in _db.ApplesToApples
					where game.GameId == id
					select game).SingleOrDefault();
		}

		public bool IsJudge(Guid id)
		{
			return true;
		}

		public void PickOndeCard()
		{
			
		}

		public void PickCards(Guid id)
		{
			var currPlayer = (from u in _db.Users
							  join gu in _db.GameUsers on u.UserId equals gu.UserId
							  where gu.GameId == id
							  select u);


			var maxPlayers = (from max in _db.ApplesToApples
							  select max.MaxPlayer).First();

			for (int i = 1; i <= maxPlayers; i++)
			{ 
				//playerArr[i] PickOneCard();
				//playerArr[i] GetNewCard();
			}
		}
	}
}